package com.ytzl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ytzl.pojo.BugUser;
import com.ytzl.service.BugUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class BugUserController {
    Map<String, Object> map = null;

    @Resource
    private BugUserService userService;

    /**
     * 查询所有用户信息
     * @return
     */
    @GetMapping("/queryUserList")
    public Map<String, Object> queryUserList() {
        List<BugUser> userList = userService.list(null);
        map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "success");
        map.put("data", userList);
        return map;
    }

    @GetMapping("queryBy")
    public BugUser queryByConditon(BugUser user){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.setEntity(user);
        BugUser bugUser = userService.getOne(queryWrapper);
        return bugUser;
    }


}
